package cn.hx.mall.goods.service.impl;

import cn.hx.mall.goods.dao.FeightTemplateDao;
import cn.hx.mall.goods.entity.FeightTemplate;
import cn.hx.mall.goods.service.FeightTemplateService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 运费模版(FeightTemplate)表服务实现类
 *
 * @author makejava
 * @since 2022-11-02 15:56:10
 */
@Service("feightTemplateService")
public class FeightTemplateServiceImpl implements FeightTemplateService {
    @Resource
    private FeightTemplateDao feightTemplateDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public FeightTemplate queryById(Long id) {
        return this.feightTemplateDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<FeightTemplate> queryAllByLimit(int offset, int limit) {
        return this.feightTemplateDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param feightTemplate 实例对象
     * @return 实例对象
     */
    @Override
    public FeightTemplate insert(FeightTemplate feightTemplate) {
        this.feightTemplateDao.insert(feightTemplate);
        return feightTemplate;
    }

    /**
     * 修改数据
     *
     * @param feightTemplate 实例对象
     * @return 实例对象
     */
    @Override
    public FeightTemplate update(FeightTemplate feightTemplate) {
        this.feightTemplateDao.update(feightTemplate);
        return this.queryById(feightTemplate.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long id) {
        return this.feightTemplateDao.deleteById(id) > 0;
    }
}